
import aioredis
from aioredis import Redis
import redis as redis_sync

# redis = aioredis.from_url(
#     "redis://127.0.0.1", port=6379, encoding="utf-8", decode_responses=True
# )

redis_pool = aioredis.ConnectionPool.from_url(
    "redis://127.0.0.1", port=6379, encoding="utf-8", decode_responses=True
)
# redis_pool = aioredis.ConnectionPool.from_url(
#     "redis://10.10.10.57", port=6379, encoding="utf-8", decode_responses=True
# )
# redis_pool = aioredis.ConnectionPool.from_url(
#     "redis://redis", port=6379, encoding="utf-8", decode_responses=True
# )

# async def get_async_redis() -> Redis:
#     async with redis.client() as conn:
#         yield conn

async def get_async_redis() -> Redis:
    return aioredis.Redis(connection_pool=redis_pool)

sync_pool = redis_sync.ConnectionPool(host='127.0.0.1', port=6379, decode_responses=True)
# sync_pool = redis_sync.ConnectionPool(host='10.10.10.57', port=6379, decode_responses=True)
# sync_pool = redis_sync.ConnectionPool(host='mysql', port=6379, decode_responses=True)

def get_sync_redis():
    return redis_sync.Redis(connection_pool=sync_pool)







































































